<html lang="en">
<head>
    <title>评论管理</title>
    <#include "../common/header.ftl">
    <script>
        $(function () {
            $(".changeBtn").click(function () {
                $("#editForm")[0].reset();
                var json = $(this).data("json");
                console.log(json);
                $("#editForm img").attr("src", "");
                if (json) {
                    $("#editForm input[name='id']").val(json.id);
                }

                $("#editModal").modal("show");
            });
            $(".submitBtn").click(function () {
                $("#editForm").ajaxSubmit(function (data) {
                    if (data.success) {
                        window.location.reload();
                    } else {
                        $.messager.confirm("温馨提示", "修改出错")
                    }
                })
            });
            //进行图片的显示操作
            var imgUrls = $(".imgUrls");
            console.log(imgUrls);
            for (var k = 0; k < imgUrls.length; k++) {
                var temp = $(imgUrls[k]);
                var imgs = temp.html().split(";");
                temp.empty();
                for (var i = 0; i < imgs.length - 1; i++) {
                    temp.append("<img src='" + imgs[i] + "' width='50px' style='margin-right:5px'/>");
                }
            }


        });
    </script>
    <style type="text/css">
        img {
            cursor: pointer;
            transition: all 0.6s;
        }

        img:hover {
            transform: scale(5.5);
            z-index: 999;
            POSITION: relative;
        }
    </style>

</head>
<body>
<!--左侧菜单回显变量设置-->
<#assign currentMenu="strategyComments">
<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-2">
            <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-10">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">评论管理</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/strategyComment/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <button id="btn_query" class="btn btn-info"><span class="glyphicon glyphicon-search"></span> 查询</button>
                <!--<button type="button" id="btn_add" class="btn btn-info changeBtn"><span class="glyphicon glyphicon-plus"></span> 添加攻略</button>--->
            </form>

            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th>评论者</th>
                    <th>时间</th>
                    <th>图片</th>
                    <th>星星</th>
                    <th>攻略</th>
                    <th>状态</th>
                    <th>内容</th>
                    <th>修改</th>
                </tr>
                </thead>
               <#list result.list as entity>
                   <tr>
                       <td>${(entity.user.nickName)!}</td>
                       <td>${entity.createTime?string("yyyy-MM-dd HH:mm:ss")}</td>
                       <td class="imgUrls">${entity.imgUrls}</td>
                       <td>${entity.starNum!}</td>
                       <td>${(entity.strategy.title)!}</td>
                       <td>${entity.stateDisplay!}</td>
                       <td>${entity.content!}</td>
                       <td>
                           <a href="javascript:void(0);" class="btn changeBtn" data-json='${(entity.jsonString)!}'>修改</a>
                       </td>
                   </tr>
               </#list>
            </table>
            <#include "../common/page.ftl">
        </div>
    </div>
</div>
<!---评论编辑--->
<div class="modal fade" id="editModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">评论编辑/增加</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/strategyComment/saveOrUpdate.do" method="post" id="editForm"
                      enctype="multipart/form-data">
                    <input type="hidden" value="" name="id">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">状态：</label>
                        <div class="col-sm-6">
                            <select class="form-control" id="state" name="state">
                                <option value="-1">全部</option>
                                <option value="0">正常</option>
                                <option value="1">推荐</option>
                                <option value="2">禁用</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary submitBtn">保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>